﻿


<?if (!empty($_POST["popupForm"])):?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
    <a href="#" id="closeForm">&times;</a>
	<form id="formPricePopup">
	<input type="hidden" name="PRODUCT" value="<?=$_POST['nameProduct'];?>" />
	<table>
	 <tr>
		 <td colspan="3" align="center"><b><?=$_POST["nameProduct"];?></b></td>
		</tr>
	 <tr>
		 <td>количество</td>
		 <td colspan="2"><input type="text" name="COUNT" width="30" value="1" /> шт.</td>
		</tr>
		
	 <tr>
		 <td>Ваше имя *</td>
		 <td colspan="2"><input type="text" name="USER_NAME" /></td>
		</tr>
	 <tr>
	 <tr>
		 <td>E-Mail *</td>
		 <td colspan="2"><input type="text" name="EMAIL" /></td>
		</tr>
	 <tr>
		 <td>телефон</td>
		 <td colspan="2"><input type="text" name="PHONE" /></td>
		</tr>
	 <tr>
		 <td>организация</td>
		 <td><input type="text" name="ORG_NAME" /></td>
		 <td>&nbsp;</td>
		</tr>
	 <tr>
		 <td>тип организации</td>
		 <td align="left">
				<label><input type="radio" name="ORG_TYPE" value="Гос.уч" checked="checked" />Гос. учереждение</label><br />
				<label><input type="radio" name="ORG_TYPE" value=">Физ.Лицо" />Физическое лицо</label><br />
				<label><input type="radio" name="ORG_TYPE" value="Юр.Лицо" />Юридическое лицо</label>
			</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
		 <td style="vertical-align: top;">коментарий</td>
			<td colspan="2">
			 <textarea cols="33" rows="10" name="COMMENT"></textarea>
			</td>
		</tr>
		<tr><td>&nbsp;</td><td><input type="button" name="" id="submitFormPopup" value="Отправить" /></td></tr>
	</table>
	</form>

</body></html>
<?
else:
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
/* добавление коментария в инфоблок и генерация почтового события */
    CModule::IncludeModule("iblock");
	$el = new CIBlockElement;
    
  	$PROP = array();  
	$PROP['USER_NAME'] = iconv("utf-8","cp1251",$_REQUEST['USER_NAME']);
	$PROP['PHONE'] = iconv("utf-8","cp1251",$_REQUEST['PHONE']);
	$PROP["EMAIL"] = iconv("utf-8","cp1251",$_REQUEST['EMAIL']);
	$PROP["COUNT"] = iconv("utf-8","cp1251",$_REQUEST['COUNT']);
	$PROP["ORG_NAME"] = iconv("utf-8","cp1251",$_REQUEST['ORG_NAME']);
	$PROP["ORG_TYPE"] = iconv("utf-8","cp1251",$_REQUEST['ORG_TYPE']);
	$PROP["PRODUCT"] = iconv("utf-8","cp1251",$_REQUEST['PRODUCT']);

	$arLoadProductArray = Array(
			"IBLOCK_TYPE"=>"info",
		  "IBLOCK_SECTION_ID" => false,
		  "IBLOCK_ID"      => 13,
		  "PROPERTY_VALUES"=> $PROP,
		  "NAME"           => $PROP["PRODUCT"],
		  "ACTIVE"         => "N",
		  "PREVIEW_TEXT"   => iconv("utf-8","cp1251",$_POST["COMMENT"])
		  );
	if ($res=$el->add($arLoadProductArray)):
			echo "Ваша заявка принята!";
	else:
		echo iconv("cp1251","utf-8","Error: ".$el->LAST_ERROR);
	endif;
endif;
?>
